<script type="text/javascript">
    layui.config({
        base: "{:C(JS_BASE_PATH)}"
    }).use(['layer','form','func'], function(){
        var layer = layui.layer,
                form = layui.form(),
                func = layui.func,
                $ = layui.jquery;
        $("[event=add]").click(function () {
            var key = $(this).parents('tr').attr('key'),
                group = $.dataSource.navs[key],
                formTpl;
            formTpl = $("[event=formTpl]");
            if(group != undefined){
                formTpl.find("input[name='pid']").val(group.id);
            }
            func.layerOpen('添加节点',formTpl.html(),'editTpl');
            form.render();
        });

        form.on('submit(add)',function (data) {
            func.ajax("{:U('ruleAdd')}",data.field);
            return false;
        });
    });
</script>